From f50cd74cf20d3d9bf6ad7041693a1e9624e5add4 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Sat, 23 Apr 2005 11:04:40 +0000 Subject: [PATCH] bitkeeper revision 1.1373 (426a2bc8m7wX71OOkLtSOgNXcrObMA) xc_domain.c: Ensure ctxt is mlocked in xc_domain_getfullinfo. --- tools/libxc/xc_domain.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index 919145e297..1d8815a8a6 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -146,7 +146,7 @@ int xc_domain_getfullinfo(int xc_handle, xc_domaininfo_t *info, full_execution_context_t *ctxt) { - int rc; + int rc, errno_saved; dom0_op_t op; op.cmd = DOM0_GETDOMAININFO; @@ -154,12 +154,23 @@ int xc_domain_getfullinfo(int xc_handle, op.u.getdomaininfo.exec_domain = (u16)vcpu; op.u.getdomaininfo.ctxt = ctxt; + if ( (ctxt != NULL) && + ((rc = mlock(ctxt, sizeof(*ctxt))) != 0) ) + return rc; + rc = do_dom0_op(xc_handle, &op); - if ( info ) + if ( ctxt != NULL ) + { + errno_saved = errno; + (void)munlock(ctxt, sizeof(*ctxt)); + errno = errno_saved; + } + + if ( info != NULL ) memcpy(info, &op.u.getdomaininfo, sizeof(*info)); - if ( ((u16)op.u.getdomaininfo.domain != domid) && rc > 0 ) + if ( ((u16)op.u.getdomaininfo.domain != domid) && (rc > 0) ) return -ESRCH; else return rc; -- 2.30.2